<template>
  <ContentWrap>
    <a-form layout="inline">
      <FormSearchInput type="text" label="SearchInput" v-model:value="searchParams.A" />
      <FormSearchInput type="number" label="SearchInput" v-model:value="searchParams.B" />
      <FormSearchSelect :dataList="userTypeList" label="SearchSelect" v-model:value="searchParams.C" />
      <a-form-item class="searchItem">
        <a-button type="primary" @click="search(true)">搜索</a-button>
        <a-button @click="search(false)">重置</a-button>
      </a-form-item>
    </a-form>
  </ContentWrap>
</template>
<script setup lang="ts">
import ContentWrap from "@/components/ContentWrap/ContentWrap.vue";
import { defineEmits, reactive } from "vue";
import { SearchParam } from "@/entity/interface/searchParams.interface";
import { UserType } from "@/entity/enum/userType.enum";
import FormSearchInput from "@/components/FormInput/FormInput.vue";
import FormSearchSelect from "@/components/FormSelect/FormSelect.vue";
import { EnumToDicData } from "@/entity/helper/enum.helper";
const emit = defineEmits(["searchParams"]);
const search = (status: boolean) => {
  if (status === false) {
    for (const key in searchParams) searchParams[key] = null;
  }
  emit("searchParams", searchParams);
};
const userTypeList = EnumToDicData(UserType);
const searchParams = reactive<SearchParam>({
  A: null,
  B: null,
  C: null,
});
</script>
<style scoped>
.searchItem {
  margin: 10px;
}
</style>
